// component/alarm/alarm.ts
import type { siteList } from "../../type/type";
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    dataList: {
      type: Array,
      value:[],
    },
  },

  /**
   * 组件的初始数据
   */
  data: {
    alarmList: [] as siteList[],
    comID:-1 as Number,
    userID:-1 as Number,
    isFresh:false as Boolean,
  },

  /**
   * 组件的方法列表
   */
  methods: {
    onDetail(e:any){
        console.log(e)
        let type = e.currentTarget.dataset.type
        let id = e.currentTarget.dataset.id
        let warnCode = e.currentTarget.dataset.warncode
        if(warnCode==0){
            wx.navigateTo({
                url:'/pages/siteDetail/siteDetail?type='+type+'&id='+id
            })
        }else{
            wx.navigateTo({
                url:'/pages/alarmDetail/alarmDetail?type='+type+'&id='+id
            })
        }
        // console.log(e)
    },
    fresh(){
        let _that = this
        _that.setData({
            isFresh:true
        })
        this.triggerEvent("getList")
        setTimeout(function () {
            _that.setData({
                isFresh:false
            })
          }, 1000)
    }
  },
  //小程序声明周期
  lifetimes: {
    attached: function () {
      // 在组件实例进入页面节点树时执行

    },
    detached: function () {
      // 在组件实例被从页面节点树移除时执行
    },
  },
  pageLifetimes: {
    show: function () {
      // 页面被展示
      this.setData({
        comID: wx.getStorageSync("userInfo").data.comID,
        userID: wx.getStorageSync("userInfo").data.userID,
      });
    //   console.log(list);
    },
    hide: function () {
      // 页面被隐藏
    },
    resize: function (size) {
      // 页面尺寸变化
    },
  },
});
